package service.factory;

import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceFactory;
import org.osgi.framework.ServiceRegistration;

public class LibraryServiceFactory implements ServiceFactory{

	public Object getService(Bundle bundle, ServiceRegistration serviceReg) {
		System.out.println("LibraryServiceFactory: getService() method");
		return new SpecialLibraryServiceImpl();
	}

	public void ungetService(Bundle bundle, ServiceRegistration serviceReg,
			Object service) {
		System.out.println("LibraryServiceFactory: ungetService() method");
		BundleContext bundleContext=bundle.getBundleContext();
		bundleContext.ungetService(serviceReg.getReference());
		
		serviceReg.unregister();
		serviceReg=null;
		service=null;
		
		
	}

}
